const textChange = require('../../../../common/util/text')

Page({
    data: {
        xPageReady : true ,
        xRead : ''
    },
    
    onLoad: function (options) {
        this.xInit(options.id)
    },
    onShareAppMessage: function () {
      return {
        title: '疼痛久治不愈？还有一招',
        path: '/pages/navigation/index/index',
        imageUrl: 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/share_all.jpg',
      };
  },
    xInit: async function (id) {
        let that = this
        await wx.cloud.callFunction({
            name: 'product_introduction',
            data: {
                action: "get_info",
                _id: id
            }
        }).then(res => {
            console.log('阅读' , res.result)
            let read = res.result
            wx.setNavigationBarTitle({
                title: read.title
            })
            if(read.title == '购买用户怎么评价？'){
                for(var i in read.info){
                    read.info[i].content = textChange.text(read.info[i].content)
                }
            }
            that.setData({
                xRead :  read.info,
            })
        })

        that.setData({
            xPageReady : false
        })
    }
})